home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
vp2_409e.szh
/
COPY.C
< prev
next >
Wrap
Text File
|
1991-06-27
|
739b
|
44 lines
#include <stdio.h>
#include <string.h>
#define DEBUG 0
copy_n_match_null (
char *str1,
char *str2,
int len)
{
int i;
int found_it;
#if DEBUG
printf("Called with len = %d\n",len);
#endif
found_it = 0;
for (i = 0; i < len; i++)
{
if (str2[i] == '\0')
break;
}
#if DEBUG
printf("After scan, i = %d\n",i);
#endif
if (i == len)
{
--found_it;
--i;
}
len = i + 1;
#if DEBUG
printf("Doing strncpy in copy.c");
printf(" with len = %d\n",len);
#endif
strncpy (str1, str2, len);
#if DEBUG
printf("Have done strncpy in copy.c\n");
#endif
if (found_it != 0)
return (-1);
else
return (len);
}